var GearsObjectReader = Class.create({
    
    context: null,
    results: null,
	current: null,
    
    initialize: function(context, results)
    {
        this.context = context;
        this.results = results;
    },
	
	read: function()
	{
		if (!this.results.isValidRow())
		{
			this.close();
			this.current = null;
			return false;
		}
		
		var classType = PersistableClass.allPersistableTypes.get(this.results.fieldByName("__type__"));
		console.log("PersistableType -->" + classType);
		var newObject = new classType();
		for (var i = 0; i < this.results.fieldCount(); i++)
		{
			if (!this.results.fieldName(i).startsWith("__"))
				newObject[this.results.fieldName(i)] = this.results.field(i);
		}
		
		this.current = newObject;
		this.results.next();
		return true;
	},
	
	close: function()
	{
		this.results.close();
	}

});
